using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Backend.JYD.AModel.Models.Mapping
{
    public class CustAssetMap : EntityTypeConfiguration<CustAsset>
    {
        public CustAssetMap()
        {
            // Primary Key
            this.HasKey(t => t.CustNo);

            // Properties
            this.Property(t => t.CustNo)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.Rank)
                .IsFixedLength()
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("CustAssets");
            this.Property(t => t.CustNo).HasColumnName("CustNo");
            this.Property(t => t.SourceId).HasColumnName("SourceId");
            this.Property(t => t.Deposit).HasColumnName("Deposit");
            this.Property(t => t.NationalDebt).HasColumnName("NationalDebt");
            this.Property(t => t.Rank).HasColumnName("Rank");
            this.Property(t => t.TaskId).HasColumnName("TaskId");
            this.Property(t => t.TaskDetailId).HasColumnName("TaskDetailId");

            // Relationships
            this.HasRequired(t => t.CustBase)
                .WithOptional(t => t.CustAsset);

        }
    }
}
